package com.yubest.designpattern.behavior.iterator;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * 迭代器-实现
 *
 * @Author: hweiyu
 * @Date: 2022/10/27 11:15
 */
@Data
@AllArgsConstructor
public class IteratorImpl implements Iterator {

    private Integer[] items;

    private Integer position;

    @Override
    public Integer next() {
        return items[position++];
    }

    @Override
    public boolean hasNext() {
        return position < items.length;
    }
}
